import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author dreamcatcher
 * @date 2022/3/2 20:36
 * 捕获分组
 */
public class RegExp07 {
    public static void main(String[] args) {
        String regStr = "(?<group1>\\d\\d)(?<group2>\\d\\d)";
        String content = "def abcdef1234 def5678aa90";

        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()){
            System.out.println("捕获到的整个字符串:"+matcher.group(0));
            System.out.println("捕获到的第一个组"+matcher.group(1));
            System.out.println("捕获到的第一个组"+matcher.group("group1"));
            System.out.println("捕获到的第二个组"+matcher.group(2));
            System.out.println("捕获到的第二个组"+matcher.group("group2"));
        }

    }
}
